/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.entity;

import java.util.Calendar;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.Pattern;
import org.eclipse.persistence.annotations.Mutable;

/**
 *
 * @author israel
 */
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "persontype", discriminatorType = DiscriminatorType.CHAR)
public abstract class Person extends AbstractEntity{

    @Pattern(regexp="(.+@.+\\.[a-z]+)?", message="Email inválido")
    @Column(length=60)
    private String email;

    @Column(length=20)
    private String phone;

    @Column(length=20)
    private String celphone;

    @ManyToOne(cascade={CascadeType.REFRESH, CascadeType.MERGE, CascadeType.DETACH})
    @JoinColumn(name="address_id",nullable=false)
    private Address address;

    @Mutable
    @Temporal(TemporalType.DATE)
    private Calendar birthday;

    @ManyToOne
    @JoinColumn(name="nationality_id")
    private Nationality nationality;
    
    @OneToMany(mappedBy = "person")
    private List<Actor> actors;
    
    @OneToMany(mappedBy = "person",fetch= FetchType.LAZY,orphanRemoval=true,
        cascade=CascadeType.ALL)
    private List<AdditionalInfo> additionalInfos;
    
    @Transient
    private List<QuestResult> questResultList;
    
    @Transient
    private Boolean agreement;
    
    public Person() {
    }

    public Person(String email, String phone, String celphone, Address address, Calendar birthday, Nationality nationality) {
        this.email = email;
        this.phone = phone;
        this.celphone = celphone;
        this.address = address;
        this.birthday = birthday;
        this.nationality = nationality;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCelphone() {
        return celphone;
    }

    public void setCelphone(String celphone) {
        this.celphone = celphone;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public Calendar getBirthday() {
        return birthday;
    }

    public void setBirthday(Calendar birthday) {
        this.birthday = birthday;
    }

    public Nationality getNationality() {
        return nationality;
    }

    public void setNationality(Nationality nationality) {
        this.nationality = nationality;
    }

    public List<QuestResult> getQuestResultList() {
        return questResultList;
    }

    public void setQuestResultList(List<QuestResult> questResultList) {
        this.questResultList = questResultList;
    }

    public Boolean getAgreement() {
        return agreement;
    }

    public void setAgreement(Boolean agreement) {
        this.agreement = agreement;
    }

    public List<Actor> getActors() {
        return actors;
    }

    public void setActors(List<Actor> actors) {
        this.actors = actors;
    }

    public List<AdditionalInfo> getAdditionalInfos() {
        return additionalInfos;
    }

    public void setAdditionalInfos(List<AdditionalInfo> additionalInfos) {
        this.additionalInfos = additionalInfos;
    }
}
